(async function(){
    if (!checkConnect()) return;
    var rtn = await loadManbers();
    if (rtn){
        var my = getMy();
        if (!my || !my.isReal){
            alert("您还不是正式会员");
            return;
        }
		setOnclick(getNode("myTab"));
        //获取可以提现的金额
        setLoading(1);
        var amount = await getWithdrawable();
        setNodeText("amount",format(amount));
        var salary = await getSalaryAmount();
        setNodeText("salary",format(salary.amount));
        setNodeText("total",format(salary.amount.add(amount)));
        loadPage("todo/myRewardYet","myTabContent");
        getNode("drawing").onclick=async function(){
            setLoading(1);
            const rtn = await withdraw("领取全部积分");
            if(rtn){
                setNodeText("amount","0");
                setNodeText("salary","0");
                setNodeText("total","0");
				loadPage("todo/myRewardYet","myTabContent");
            }
            setLoading(0);
        };
    }

	/**
	* 切换不同的标签页
	*/
	function enable(div){
		var par = div.parentNode.parentNode;
		for(var i=0;i<par.children.length;i++){
			par.children[i].children[0].ariaSelected="false";
			par.children[i].children[0].className="nav-link ab-tab-item";
		}
		div.ariaSelected="true";
		div.className="nav-link active ab-tab-item";
	}
	
	/**
	* 设置每个标签页的点击事件
	*/ 
	function setOnclick(node){
		for(var i=0;i<node.children.length;i++){
			if (node.children[i].id.substr(0,4)=="todo"){
				node.children[i].onclick = function(){
					enable(this);
					loadPage(this.id,"myTabContent");
				};
			}
			if(node.children[i].children.length>0) {
			  setOnclick(node.children[i]);
			}
		}
	}	
})();